<template>
    <view class="opportunityManage">
        <uni-nav-bar fixed left-icon="left" @clickLeft="backHandle" title="退款记录" class="unibarS">
        </uni-nav-bar>
        <view v-if="list.length" class="list">
            <view class="item" v-for="(item, index) in list" :key="index">
                <view class="item-top">
                    <view class="item-top-left">
                        <view class="rate">退款日期：{{ item.createTime }}</view>
                        <view class="time">退款金额：¥ {{ item.refundAmount }}</view>
                    </view>
                    <!-- <view class="item-top-right">
                        <u-icon name="arrow-right" color="#0C1019" size="20"></u-icon>
                    </view> -->
                </view>
            </view>
            <uni-load-more :status="status" />
        </view>
        <empty-view v-else />
    </view>
</template>

<script>
export default {
    data() {
        return {
            params: {
				customerId: null,
				pageNum: 1,
				pageSize: 20
			},
			total: 0,
			status: 'loading',
			refresh: false,
			list: []
        }
    },
    onLoad(options) {
        if(options.customerId) {
            this.params.customerId = options.customerId
            this.getData()
        }
	},
    onReachBottom() {
		console.log('上拉加载onReachBottom')
		if (this.status == 'noMore' || this.status == 'loading') return
		this.params.pageNum = this.params.pageNum + 1
		this.status = 'loading'
		this.getData()
	},
    methods: {
        getData() {
			this.$http.get('/app/customer/refundList', this.params).then(res => {
				if (res.code == 200) {
					this.list = [...this.list, ...res.rows]
					this.total = res.total
					if (this.total > this.list.length) {
						console.log('有更多数据')
						this.status = 'more'
					} else {
						console.log('没更多数据')
						this.status = 'noMore'
					}
					// if (this.refresh) {
					// 	uni.stopPullDownRefresh()
					// }
				} else {
					uni.$u.toast(res.msg)
				}
			})
		},
        addOrder() {
            uni.navigateTo({
                url: '/pages/order/addOrder'
            });
        },
        searchHandle() {
			this.params.pageNum = 1
			this.status = 'loading'
			this.list = []
			this.getData()
		},
        seeMoney() {
            this.$refs.popup.open()
        },
        closePopup() {
            this.$refs.popup.close()
        },
        goDetails(index) {
            uni.navigateTo({
                url: '/pages/opportunity/opportunityDetails'
            });
        },
        backHandle() {
            uni.navigateBack()
        }
    }
}
</script>

<style lang="scss" scoped>

.item {
    padding: 32rpx;
    border-radius: 24rpx;
    background: rgba(255, 255, 255, 1);
    margin-top: 20rpx;

    .item-top {
        display: flex;
        justify-content: space-between;
        align-items: center;

        .item-top-left {
            flex: 1;
            margin-right: 20rpx;
            width: 0;

            .name {
                font-size: 32rpx;
                font-weight: 500;
                color: rgba(12, 16, 25, 1);
                margin-bottom: 32rpx;
                // 超出显示省略号
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }

            .rate,
            .time {
                font-size: 28rpx;
                font-weight: 400;
                color: rgba(103, 117, 133, 1);
            }
            .rate {
                margin-bottom: 26rpx;
            }
        }

        .item-top-right {
            width: 150rpx;
            display: flex;
            flex-direction: column;
            justify-content: flex-end;
            align-items: flex-end;
            text-align: right;
            > view {
                width: 100%;
                display: flex;
                flex-direction: column;
                align-items: flex-end;
            }
            .salesman {
                margin-top: 8rpx;
                font-size: 28rpx;
                font-weight: 500;
                color: rgba(12, 16, 25, 1);
                width: 100%;
                // 超出隐藏
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }
        }
    }
}

</style>